<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    a {
      text-decoration: none;
      color: #000;
      display: block;
      width: 100%;
    }

    h3 {
      text-align: center;
      height: 60px;
      line-height: 60px;
      background-color: rgb(212, 12, 12);
      color: #fff;
    }

    ul {
      list-style: none;
    }

    li {
      padding: 10px 15px;
      border-bottom: 1px solid #ccc;
    }
  </style>
</head>

<body>
  <h3>商品列表</h3>
  <ul id="list">
    <li data-id="">
      <span data-name="">商品</span>
      <span data-price="">1823</span>
    </li>
  </ul>
  <!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script> -->
  <script src="http://localhost:7001/package/axios.min.js"></script>
  <script src="http://localhost:7001/js/axios.js"></script><!-- 拦截器 -->
  <script>
    ; (async function () {
      const res = await axios({
        method: 'get',
        url: `/api/goodsList`,
        params: { currentPage: 1, pageSize: 10 }
      })

      console.log('-----', res);


      list.innerHTML = res.data.res.map(item => {
        return `
          <li data-id="${item.id}">
            <a href="/detail/${item.id}">
              <span data-name="${item.id}">${item.name}</span>
              <span data-price="${item.id}">${item.price}</span>  
            </a>
          </li>
        `
      }).join('')
    })()
  </script>
</body>

</html>